package com.bnz.search.controller;

import com.bnz.search.entity.ItemVo;
import com.bnz.search.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;


@Controller
public class SearchController {
	@Autowired
	private ItemService itemService;

	//1、商品搜索
	@GetMapping({"/","/index.html"})
	public String search(Model model, ItemVo vo){
		System.out.println("vo = " + vo);
		//1.1、开始查询商品
		Map<String,Object> resultMap = itemService.search(vo);
		//1.2、将查询的结果放到model中
		model.addAttribute("resultMap",resultMap);
		model.addAttribute("vo",vo);
		return "search";
	}
}
